package com.juyu.miliao.api.dao.mysql;

import com.juyu.miliao.api.domain.OfficialQuestionToAnswerInfo;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author xuanqicheng
 * @create 2018-18-11:02 AM
 */
@Repository
public class OfficialQuestionToAnswerDao {
    @Autowired
    private SqlSession sqlSession;
    public OfficialQuestionToAnswerInfo checkQuestionAnsweringByOfficialQuestionIdAndAnswerUserId(
            OfficialQuestionToAnswerInfo entity) {

        return sqlSession.selectOne("checkQuestionAnsweringByOfficialQuestionIdAndAnswerUserId",entity);
    }

    public void createInfo(OfficialQuestionToAnswerInfo officialQuestionToAnswerInfo) {

        sqlSession.insert("addInfo",officialQuestionToAnswerInfo);

    }

    public List<Long> getAnswerIdByOfficialQuestionId(Integer officialQuestionId) {

        return sqlSession.selectList("getAnswerIdByOfficialQuestionId",officialQuestionId);

    }

    public OfficialQuestionToAnswerInfo getNewOfficialQuestionToAnswerInfoByOfficialQuestionId(Integer officialQuestionId) {
        return sqlSession.selectOne("getNewOfficialQuestionToAnswerInfoByOfficialQuestionId",officialQuestionId);
    }

    public List<OfficialQuestionToAnswerInfo> selectPageByQuestionId(Map<String, Object> parameterMap) {

        return sqlSession.selectList("selectPageByQuestionId",parameterMap);
    }

    public OfficialQuestionToAnswerInfo selectOfficialAnswerById(Integer id) {
        return sqlSession.selectOne("selectOfficialAnswerById",id);
    }
}
